package sn.hn.demo.unit;

import java.util.Random;

import sn.hn.demo.MainActivity;
import sn.hn.demo.image.ImageData;
import sn.hn.demo.sprite.MySprite;
import android.content.Context;
import android.graphics.Bitmap;

public class Bubbles extends Unit {
	public Bitmap bubbles;
	public Bitmap bubbles1;
	public Bitmap bubbles2;
	public Bitmap bubbles3;
	public Bitmap bubbles4;
	public Bitmap bubbles5;
	public Bitmap bubbles6;
	public MySprite mSprite;
	Random r= new Random();
	public boolean isDie;
	public Bubbles(Context context) {
		super(context);
		this.isDie = false;
		this.x = r.nextInt(2000)%MainActivity.SCREENWIDTH;
		this.y = MainActivity.SCREENHEIGHT + r.nextInt(80);
		getBitmap(context);
		this.mSprite = new MySprite(x, y);
		init();
	}
	
	public void init()
	{
		switch (r.nextInt(30)%5) {
		case 0:
			this.mSprite.init(bubbles);
			break;
		case 1:
			this.mSprite.init(bubbles1);
			break;
		case 2:
			this.mSprite.init(bubbles2);
			break;
		case 3:
			this.mSprite.init(bubbles3);
			break;
		case 4:
			this.mSprite.init(bubbles4);
			break;
		case 5:
			this.mSprite.init(bubbles5);
			break;
		case 6:
			this.mSprite.init(bubbles6);
			break;
		default:
			this.mSprite.init(bubbles);
			break;
		}
	}
	
	public void getBitmap(Context context)
	{
		bubbles = ImageData.mBubbles1;
		bubbles1 = ImageData.mBubbles2;
		bubbles2 = ImageData.mBubbles3;
		bubbles3 = ImageData.mBubbles4;
		bubbles4 = ImageData.mBubbles5;
		bubbles5 = ImageData.mBubbles6;
	}
	
	
	public void moveBubbles()
	{
		if(!this.isDie)
		{
			if(this.y > 3*MainActivity.SCREENHEIGHT/8)
			{
				this.y--;
				this.mSprite.yPos = y;
			}else{
				isDie = true;
			}
		}
	}
}
